{% extends 'worker.html'%}
{%block content%}
<div class="container">
    <div style="margin-bottom:15px;">
        <input id="btnAdd"type="button"class="btn btn-primary" value="客户信息">
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">{{title}}</h3>
        </div>
        <div class="panel-body">
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>客户姓名</th>
                        <th>纯净水</th>
                        <th>数量</th>
                        <th>操作</th>
                        
                    </tr>
                </thead>
                <tbody>
                    {% for obj in queryset %}
                    <tr>
                        <td>{{obj.id}}</td>
                        <td>{{obj.cname}}</td>
                        <td>{{obj.pname}}</td>
                        <td>{{obj.num}}</td>
                       
                        <td>
                           
                            <!-- <a href="/pretty/{{obj.id}}/edit/"class='btn btn-primary btn-xs'>编辑</a>  -->
                          
                                <input uid="{{obj.id}}"id="{{forloop.counter}}"type="button"value={{obj.get_state2_display}} class="btn btn-primary btn-xs btn-reserve">

                          
                        </td>
                       
                         
                           
                       
                    
                
                           
                    </tr>
                    {%endfor%}
                </tbody>
            </table>
            <ul class="pagination">
                {{page_string}}
             </ul>
        </div>
        <div>

        </div>
    </div>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
              <h4 class="modal-title" id="myModalLabel">客户信息</h4>
            </div>
            <div class="modal-body">
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>客户姓名</th>
                            <th>地址</th>
                            <th>联系方式</th>
                            
                        </tr>
                    </thead>
                    <tbody>
                        {% for obj in querysets %}
                        <tr>
                            <td>{{obj.cname}}</td>
                            <td>{{obj.caddr}}</td>
                            <td>{{obj.cmobile}}</td>
                               
                        </tr>
                        {%endfor%}
                    </tbody>
                </table>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
             
            </div>
          </div>
        </div>
    </div>
    <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="alert alert-danger alert-dismissible fade in" role="alert">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4>已申请，请耐心等待</h4>
                <p style="text-align:right">
                  
                  <button type="button" class="btn btn-default"data-dismiss="modal">关 闭</button>
                </p>
              </div>
              
            </div>
          </div>
        </div>
        <div class="modal fade" id="deleteModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
              <div class="modal-content">
                <div class="alert alert-danger alert-dismissible fade in" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
                    <h4>已审核，请选择其他订单</h4>
                    <p style="text-align:right">
                      
                      <button type="button" class="btn btn-default"data-dismiss="modal">关 闭</button>
                    </p>
                  </div>
                  
                </div>
              </div>
            </div>
</div>
{% endblock %}
{% block js%}
<script>
    var change=0;
    $(function(){
            bindBtnAddEvent();
            bindBtn1Event();
        })
    function bindBtnAddEvent(){
        $("#btnAdd").click(function(){
            $("#myModal").modal("show");
        })    
    }
    function bindBtn1Event(){
        $('.btn-reserve').click(function(){
            nid=$(this).attr("id")
            uid=$(this).attr("uid")
            // $("#"+nid).attr('value','已申请'); 
            // $("#"+nid).parent().next().text('审核中'); 
            change=1;
                $.ajax({
                    url:'/worker_reserve/',
                    type:"get",
                    data:{
                        uid:uid,
                        id:$("#cinfo").attr("uid"),
                        name:$("#cinfo").text(),
                    },
                    dataType:"JSON",
                    success:function(res){
                        if(res.status){
                            // if(res.s=="已审核"){
                            //     $("#deleteModal2").modal("show");
                            // }
                            location.reload()
                           
                        }else{
                            $("#deleteModal").modal("show");
                        }
                    }
                })
            })
        
    }

        
</script>
{% endblock%}